<template>
<div id="dv1">
  <div>
    <van-nav-bar
        title="编辑个人资料"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft()"
    />
  </div>
  <div>
    <div class="dv2">
      <van-image
          width="100%"
          height="200px"
          fit="cover"
          position="left"
          src="https://img1.baidu.com/it/u=2155872813,2247325734&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
      />
    </div>
      <div id="dv4">
        <van-cell-group inset>
          <!-- 输入任意文本 -->
          <van-field v-model="user.nickname" label="昵称" />
          <van-row gutter="20">
            <van-col span="5"><label id="h5">性别</label></van-col>

            <van-col span="19"><van-radio-group v-model="user.sex" direction="horizontal"  >
              <van-radio name="1">男</van-radio>
              <van-radio name="0">女</van-radio>
            </van-radio-group></van-col>
          </van-row>

          <!-- 输入手机号，调起手机号键盘 -->
          <van-field v-model="user.phone" type="tel" label="手机号" />
          <!-- 允许输入正整数，调起纯数字键盘 -->
          <van-field v-model="user.email" label="邮箱" />

        </van-cell-group>

      </div>
    <div>
      <van-button type="primary" block @click="btn1()">保存</van-button>

    </div>
  </div>
</div>
</template>

<script>
export default {
  name: "MyInformation",


  data(){
    return {
      user:{
      nickname: "",
      phone: "",
      sex: "",
      email: ""
    }
    }
  },
  mounted() {
    this.select();
  },
  methods:{
    onClickLeft(){
      history.back();
    },
    select(){
      this.axios.get("/user/selectOne.do").then(res=>{
        if(res.data.code==200){
          this.user=res.data.data;
        }
      })
    },
    btn1(){
      this.axios.post("/user/updateData.do",this.user).then(res=>{
        if(res.data.code==200){
          this.$toast("修改成功")
        }else {
          this.$toast("修改失败")
        }
      })
    }
  }
}
</script>

<style scoped>
#dv1{
  background-color: #F2F2F2;
}

#dv2{
  background-color: #FFFFFF;
}
#dv3{
margin-top: 10px;
  background-color:#FFFFFF ;
}
#dv4{
  margin-top: 10px;
  height: 200px;
}
#h5{
  margin: 0px;
  font-size: 12px;
}
</style>